package com.playtime.layouts.example1;

import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;

public class HBoxConstraints extends Constraints {

    private Priority hgrow;
    private Insets margin;

    public Priority getHgrow() {
        return hgrow;
    }

    public void setHgrow(Priority hgrow) {
        this.hgrow = hgrow;
    }

    public Insets getMargin() {
        return margin;
    }

    public void setMargin(Insets margin) {
        this.margin = margin;
    }

    @Override
    public void apply(Node node) {

        // just so we can see the HGrow work turn off the stupid Max size thing
        ((Control)node).setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

        if (hgrow != null) {
            HBox.setHgrow(node, hgrow);
        }
        if (margin != null) {
            HBox.setMargin(node, margin);
        }
    }
}
